#include "ConvertGenes.h"

ConvertGenes::ConvertGenes()
{
}

QString ConvertGenes::convert(Candidate *candidate) {
    QString converted;
    //Rhythms
    int i = 0;
    while(i<candidate->getGenome().size()) {
        switch((int)candidate->getChromosome(i)) {
        case 0:
            converted.append("s");
            break;
        case 1:
            converted.append("s");
            break;
        case 2:
            converted.append("s");
            break;
        case 3:
            converted.append("e");
            break;
        case 4:
            converted.append("e");
            break;
        case 5:
            converted.append("q");
            break;
        case 6:
            converted.append("E");
            break;
        case 7:
            converted.append("Q");
            break;

        }
        i++;
        converted.append(returnArg(candidate,i));
        i++;
        converted.append(returnArg(candidate,i));
        i++;
        converted.append(returnArg(candidate,i));
        i++;
        converted.append(returnArg(candidate,i));
        i++;
        converted.append(returnArg(candidate,i));
        i++;
    }

    return converted;
}

QString ConvertGenes::returnArg(Candidate *candidate, int index) {
    QString num;
    num.setNum((int)candidate->getChromosome(index));
    if(candidate->getChromosome(index)<10) {
        num.prepend("00");
    } else if(candidate->getChromosome(index)<100) {
        num.prepend("0");
    }
    return num;
    num;
}
